package model.Service;

import java.util.List;

import model.DAO.VoteOptionDAO;
import model.Entity.Web.VoteOption;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("VoteOptionService")
@Transactional(readOnly=true)
public class VoteOptionService {
	
	@Autowired
	VoteOptionDAO voteOptionDAO;
	
	public List<VoteOption> getAll(){
		return voteOptionDAO.findAll();
	}
	
	public List<VoteOption> getQuestionOptions(Integer voteId){
		return voteOptionDAO.findByVoteID(voteId);
	}
	
	@Transactional(readOnly=false)
	public void updateVoteResult(Integer voteId, Integer optionId){
		voteOptionDAO.updateVote(voteId, optionId);
	}

}
